package code.jam.view;

import java.util.ArrayList;
import java.util.List;

import my.andoird.util.r1.JamThread;

import android.content.Context;
import android.widget.ImageView;
import code.jam.R;

class LoadingView extends ImageView implements Runnable
{
	Context context = null;
	boolean	on = true;
	List<Integer> list = null;
	
	public LoadingView(Context context)
	{
		super(context);
		this.context = context;
		initiate();
	}
	
	public void initiate()
	{
		list = new ArrayList<Integer>(8);
		
		list.add(R.drawable.loading_mb_0001);
		list.add(R.drawable.loading_mb_0002);
		list.add(R.drawable.loading_mb_0003);
		list.add(R.drawable.loading_mb_0004);
		list.add(R.drawable.loading_mb_0005);
		list.add(R.drawable.loading_mb_0006);
		list.add(R.drawable.loading_mb_0007);
		list.add(R.drawable.loading_mb_0008);
	}

	public void run() 
	{
		while(on)
		{
			for(int i = 0; i < 1; i++)
			{
				setBackgroundResource(list.get(i));
				JamThread.sleep( 150 );				
			}
		}
	}
	
	public void stop()
	{
		on = false ;
	}
	
	public void start()
	{
		Thread thread = new Thread(this, "LODING_THREAD");
		
		thread.start();
	}
}
